package Java语言.数据结构.互转.Object数组和List;

import java.util.ArrayList;
import java.util.Arrays;

public class ArrayListToObjectArray {
    public static void main(String[] args) {
        //用数组初始化ArrayList
        ArrayList<Integer> s = new ArrayList<>(Arrays.asList(1, 2, 3));
        System.out.println(s);
        //注意传参
        Integer[] t = s.toArray(new Integer[2]);
        System.out.println(Arrays.toString(t));//调用每个元素的toString()，实现serializable


    }
}
